<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="数据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataDt">
              <j-date placeholder="请输入数据日期" v-model="model.dataDt"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="金融机构代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jrjgdm">
              <a-input v-model="model.jrjgdm" placeholder="请输入金融机构代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="内部机构号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nbjghm">
              <a-input v-model="model.nbjghm" placeholder="请输入内部机构号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贷款合同编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dkthbm">
              <a-input v-model="model.dkthbm" placeholder="请输入贷款合同编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贷款借据编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dkjjbm">
              <a-input v-model="model.dkjjbm" placeholder="请输入贷款借据编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否个体工商户贷款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfgtgshdk">
              <a-input v-model="model.sfgtgshdk" placeholder="请输入是否个体工商户贷款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否小微企业主贷款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfxwqyzdk">
              <a-input v-model="model.sfxwqyzdk" placeholder="请输入是否小微企业主贷款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否涉农贷款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfsmdk">
              <a-input v-model="model.sfsmdk" placeholder="请输入是否涉农贷款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="涉农贷款类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="smdklx">
              <a-input v-model="model.smdklx" placeholder="请输入涉农贷款类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否精准扶贫贷款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfjzfpdk">
              <a-input v-model="model.sfjzfpdk" placeholder="请输入是否精准扶贫贷款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否建档立卡贫困人口贷款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfjdlkfkrkdk">
              <a-input v-model="model.sfjdlkfkrkdk" placeholder="请输入是否建档立卡贫困人口贷款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否地方政府融资平台贷款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfdfzfrzpddk">
              <a-input v-model="model.sfdfzfrzpddk" placeholder="请输入是否地方政府融资平台贷款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="地方融资平台按法律性质分类类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dfrzptaflxzfllx">
              <a-input v-model="model.dfrzptaflxzfllx" placeholder="请输入地方融资平台按法律性质分类类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="地方融资平台按隶属关系分类类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dfrzptalsgxfllx">
              <a-input v-model="model.dfrzptalsgxfllx" placeholder="请输入地方融资平台按隶属关系分类类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="地方融资平台偿债资金来源分类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dfrzptczzjlyfl">
              <a-input v-model="model.dfrzptczzjlyfl" placeholder="请输入地方融资平台偿债资金来源分类"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否保障性安居工程贷款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfbzxajgcdk">
              <a-input v-model="model.sfbzxajgcdk" placeholder="请输入是否保障性安居工程贷款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="保障性安居工程贷款类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bzxajgcdklx">
              <a-input v-model="model.bzxajgcdklx" placeholder="请输入保障性安居工程贷款类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否绿色贷款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sflsdk">
              <a-input v-model="model.sflsdk" placeholder="请输入是否绿色贷款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否创业担保贷款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfcydbdk">
              <a-input v-model="model.sfcydbdk" placeholder="请输入是否创业担保贷款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="创业担保贷款类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cydbdklx">
              <a-input v-model="model.cydbdklx" placeholder="请输入创业担保贷款类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="科目代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectNo">
              <a-input v-model="model.subjectNo" placeholder="请输入科目代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="科目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectName">
              <a-input v-model="model.subjectName" placeholder="请输入科目名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khmc">
              <a-input v-model="model.khmc" placeholder="请输入客户名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khdm">
              <a-input v-model="model.khdm" placeholder="请输入客户代码"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'JsPLoanSpeciForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/jsPLoanSpeci/jsPLoanSpeci/add",
          edit: "/jsPLoanSpeci/jsPLoanSpeci/edit",
          queryById: "/jsPLoanSpeci/jsPLoanSpeci/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>
